/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.opgea.token.web.dto;

import java.io.Serializable;

import com.opgea.token.domain.entities.Company;
import com.opgea.token.domain.interfaces.Marshallable;

/**
 * 
 * @author Ramesh
 */
public class CompanyDTO implements Serializable, Marshallable<Company> {

    private static final long serialVersionUID = -3292966450191343821L;
    private Long companyId;
    private String name;

    private Long countryId;
    private Long cityId;
    private String website;
    private String email;

    private boolean isActive;

    public CompanyDTO() {
    }

    public String getEmail() {
	return email;
    }

    public void setEmail(String email) {
	this.email = email;
    }

    public String getName() {
	return name;
    }

    public void setName(String name) {
	this.name = name;
    }

    public String getWebsite() {
	return website;
    }

    public void setWebsite(String website) {
	this.website = website;
    }

    public Long getCityId() {
	return cityId;
    }

    public void setCityId(Long cityId) {
	this.cityId = cityId;
    }

    public Long getCountryId() {
	return countryId;
    }

    public void setCountryId(Long countryId) {
	this.countryId = countryId;
    }

    public Long getCompanyId() {
	return companyId;
    }

    public void setCompanyId(Long companyId) {
	this.companyId = companyId;
    }

    public boolean getIsActive() {
	return isActive;
    }

    public void setIsActive(boolean isActive) {
	this.isActive = isActive;
    }

    @Override
    public String toString() {
	return "CompanyForm{" + "companyName=" + name + ", email=" + email
		+ ", website=" + website + '}';
    }

    /**
     * Copy values from Company entity to CompanyDTO
     */
    @Override
    public void marshall(Company company) {
	this.companyId = company.getId();
	this.name = company.getName();
	if (company.getDetails() != null) {
	    this.website = company.getDetails().getWebsite();
	    this.cityId = company.getDetails().getCityId();
	    this.countryId = company.getDetails().getCountryId();
	    this.email = company.getDetails().getEmailId();
	}
	this.isActive = company.isActive();
    }

    /**
     * Copy values from CompanyDTO to Company
     */
    @Override
    public Company unmarshall(Company company) {
	if (this.companyId > 0) {
	    company.setId(this.companyId);
	}
	company.setName(this.name);
	company.setActive(this.isActive);
	if (company.getDetails() != null) {
	    company.getDetails().setWebsite(this.website);
	    company.getDetails().setCityId(this.cityId);
	    company.getDetails().setCountryId(this.countryId);
	    company.getDetails().setEmailId(this.email);
	}
	return company;
    }

}
